<?php
/**
 * Created by PhpStorm.
 * User: denh
 * Date: 16/5/10
 * Time: 下午5:35
 */

class System_configController extends BaseController {

    public $config = array(
        'key1' => '扫医生码直接通过医生审核', # 1开启， 0关闭
    );

    function index() {
        $do = new DoSystem_config();
        $do->set_c_key('key1');
        $do->loadFromDB();
        $data['is_on'] = $do->get_c_value();
        $this->initScript($data);
        require $this->template;
    }

    function index_post() {
        $key = $this->request('key');
        $value = $this->request('value');

        if (!array_key_exists($key, $this->config)) {
            $this->errorPage('参数 key 错误');
        }
        $do = new DoSystem_config();
        $do->set_c_key($key);
        $do->loadFromDB();
        $do->set_c_value($value);
        $do->set_c_name($this->config[$key]);
        $do->set_updateTime(date("Y-m-d H:i:s"));
        if ($do->save()) {
            $this->jsonOutPut(0, 'ok');
        }

    }



}